/**
 * @author zy
 * @version 1.0
 * @date 2021/3/16 10:46
 */

import com.lagou.EmailApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@SpringBootTest(classes = {EmailApplication.class})
@RunWith(SpringJUnit4ClassRunner.class)
public class SendMail {

    @Autowired
    private JavaMailSender javaMailSender;

    @Test
    public void context(){
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setSubject("测试邮件-java邮件任务");//邮件主题
        simpleMailMessage.setText("测试邮件,测试java发送邮件任务......");//邮件内容
        simpleMailMessage.setTo("1094253418@qq.com");//邮件发给谁
        simpleMailMessage.setFrom("1094253418@qq.com"); //邮件来自于谁
        javaMailSender.send(simpleMailMessage);
    }

}
